<template>
	<div class="communication-table">
		<div class="am-u-sm-12">
            <el-table
              :data="tableData"
              border
              stripe
              empty-text="暂无数据"
              style="min-width: 100%">
              <el-table-column
                prop="className"
                align="center"
                label="科目/班级"
                min-width="100">
              </el-table-column>
              <el-table-column
                label="主讲教师"
                prop="teacherName"
                align="center"
                min-width="100">
              </el-table-column>
              <el-table-column
                align="center"
                label="学生成绩"
                min-width="100">
                <template scope="scope">
	                <div class="am-u-sm-12 input-field" v-if="edit">
			        	<input type="number"  class="am-form-field" placeholder="请输入成绩" v-model="scope.row.score" >
			        </div>
			        <div v-else>{{ scope.row.score }}</div>
				</template>
              </el-table-column>
              <el-table-column
                label="学生是否有收获"
                align="center"
                min-width="100">
                <template scope="scope">
	                <div class="am-u-sm-12 input-field" v-if="edit">
			        	<select2 required v-model="scope.row.haveHarvest">
				            <option value="1">有收获</option>
				            <option value="0">无收获</option>
			        	</select2>
			        </div>
			        <div v-else>{{ haveHarvest[scope.row.haveHarvest] }}</div>
			    </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="其他要求"
                prop="otherRequire"
                min-width="100">
                <template scope="scope">
	                <div class="am-u-sm-12 input-field" v-if="edit">
			        	<input type="text"  class="am-form-field" maxlength="250" placeholder="250字以内" v-model="scope.row.otherRequire" >
			        </div>
			        <div v-else>{{ scope.row.otherRequire }}</div>
				</template>
              </el-table-column>
              <!-- <el-table-column
                align="center"
                label="在读总讲次"
                min-width="100">
                <template scope="scope">
                	{{ (scope.row.lectureNum || 0)}}
                </template>
              </el-table-column> -->
            </el-table>
        </div>
	</div>
</template>
<script>
	import io from '../../lib/io'
	export default{
		data(){
			return {
				tableData: [],
				studentCommunicateId: this.$route.query.studentCommunicateId,
				haveHarvest:{
					'0': '无收获',
					'1': '有收获',
				},
			}
		},
		props:['edit'],
		methods:{
			loadStudentInfo(){
		        io.post(io.findStudentRegByCommunicateId, {studentCommunicateId: this.studentCommunicateId},
		          (ret) => {
		            if (ret.success) {
		              this.tableData = ret.data;

		              for(let i = 0 ; i < this.tableData.length ; i ++){
		              	this.tableData[i].haveHarvest = '1'
		              }

		        }})
		    },
		},
		created(){
			if(this.edit){
				this.loadStudentInfo();
			}
		},
	}
</script>
<style scoped>
	.communication-table input{
		text-align: center;
	}
</style>
